package com.yanqu.road.server.cmd.kuang.cross;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.kuang.Kuang;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.command.Command;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.manger.player.GamePlayerMgr;
import com.yanqu.road.server.protocol.GameProtocol;
import io.netty.channel.ChannelHandlerContext;

@Cmd(code = GameProtocol.S_KUANG_NOTIFY_CONDITION_FROM_CROSS, desc = "同步condition更新  跨服返回")
public class KuangNotifyConditionFromCrossCmd implements Command {

    @Override
    public void execute(ChannelHandlerContext ctx, YanQuMessage packet) throws Exception {
        Kuang.CrossKuangNotifyConditionRespMsg respMsg = Kuang.CrossKuangNotifyConditionRespMsg.parseFrom(packet.getBytes());
        GamePlayer onlinePlayer = GamePlayerMgr.getOnlinePlayer(respMsg.getUserId());
        if (onlinePlayer != null) {
            onlinePlayer.notifyListener(respMsg.getConditionType(), respMsg.getValue());
        }
    }

}
